package com.karst.essentials.chapter10
{
	import flash.events.Event;
	
	import org.aswing.AsWingManager;
	import org.papervision3d.core.geom.Particles;
	import org.papervision3d.view.BasicView;

	internal class ParticleTemplate extends BasicView
	{
		private var reachX : Number = .1 ;
		private var reachY : Number = .1 ;
		private var reachZ : Number = .5 ;
		private var easeOut : Number = .3 ;
		
		protected var numOfPartices : uint = 0 ;
		protected var particles : Particles = null ;
		
		public function ParticleTemplate()
		{
			super( 640, 640, true, true ) ;
			createView() ;
			startRendering() ;
		}

		protected function createView() : void
		{
			numOfPartices = 1000 ;
			if( particles == null )
				particles= new Particles() ;
			scene.addChild( particles ) ;
		}
		
		protected function randPos() : int 
		{
			return Math.random() * 4000 - 2000 ;
		}
		
		override protected function onRenderTick( $event : Event = null ) : void
		{
			super.onRenderTick( $event ) ;
			camera.x += (( mouseX - AsWingManager.getStage().stageWidth ) * .5 
				- camera.x * reachX ) * easeOut ;
			camera.y += (( mouseY - AsWingManager.getStage().stageHeight ) * .5
				- camera.y * reachY ) * easeOut ;
			camera.z = ( - mouseY * 2 - camera.z ) * reachZ ;
		}
	}
}